//
//  ProfileViewCell.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2020/2/8.
//  Copyright © 2020 tao Tao. All rights reserved.
//

import UIKit

enum ProfileCellType: Int {
    case changePwd
    case advisory
}

protocol ProfileViewCellDelegate: NSObjectProtocol {
    func receiveAdvisory(isReceive: Bool)
}

class ProfileViewCell: UITableViewCell {
    
    static let reuseIdentifier = "profileCellID"
    
    weak var delegate: ProfileViewCellDelegate?
    
    func configure(title: String, cellType: ProfileCellType) {
        titleLabel.text = title
        switchBtn.isHidden = cellType != .advisory
        arrowView.isHidden = cellType != .changePwd
    }

    @IBOutlet private weak var titleLabel: UILabel!
    @IBOutlet private weak var switchBtn: UIButton!
    @IBOutlet private weak var arrowView: UIImageView!
    
    @IBAction private func switchBtnClicked(_ sender: UIButton) {
        sender.isSelected.toggle()
        delegate?.receiveAdvisory(isReceive: sender.isSelected)
    }

}
